{template header member}

<div class="margin-big-top layout">
	<div class="container border border-gray-white member clearfix">
		<div class="left padding-big">
			<div class="user-head margin-big-left margin-big-top">
				<img src="<?php echo $member['avatar'];?>" height="148" />
				<span><a href="{url('member/account/avatar')}">修改头像</a></span>
			</div>
			<div class="margin-top text-center text-default"><p><?php echo $member['_group']['name'] ?></p></div>
			{template menu_index member}
		</div>
		<div class="right padding-big-left padding-big-right">
			<div class="member-order-top margin-top margin-bottom small-search clearfix">
				<div class="fl padding-small-top">
					<ul class="order-menu">
						<li><a {if (!isset($_GET[type])|| !in_array($_GET[type],array(1,3,4,7)))}class="current"{/if} href="{url('member/order/index')}">全部订单</a></li>
						<li><a {if ($_GET[type] == 1)}class="current"{/if} href="{url('member/order/index',array('type'=>1))}">待付款(<?php echo $member['counts'][pay] ?>)</a></li>
						<li><a {if ($_GET[type] == 3)}class="current"{/if} href="{url('member/order/index',array('type'=>3))}">待发货(<?php echo $member['counts'][delivery] ?>)</a></li>
						<li><a {if ($_GET[type] == 4)}class="current"{/if} href="{url('member/order/index',array('type'=>4))}">待收货(<?php echo $member['counts'][receipt] ?>)</a></li>
						<li><a class="text-gray {if ($_GET[type] == 7)}current{/if}" href="{url('member/order/index',array('type'=>7))}">订单回收站(<?php echo $member['counts'][recycle] ?>)</a></li>
						<div class="mat"></div>
					</ul>
				</div>
				<div class="fr search border">
					<form class="clearfix" name="form-search" method="get">
						<input type="hidden" name="m" value="member"/>
						<input type="hidden" name="c" value="order" />
						<input type="hidden" name="a" value="index" />
						<input class="input border-none bg-none fl" type="text" placeholder="{if $_GET[sn]}{$_GET[sn]}{else}请输入订单号{/if}" name="sn" />
						<input class="button text-small text-white radius-none border-none bg-gray-white fr" type="submit" value="查询">
					</form>
				</div>
			</div>
			<div class="table-wrap">
				<div class="order-table-th text-center">
					<div class="td"><div class="column-wide">订单详情</div></div>
					<div class="td"><div class="column-narrow">收货人</div></div>
					<div class="td"><div class="column-narrow">总计</div></div>
					<div class="td">
						<div class="column-narrow o-stutas-filter">
							<div><span class="open">全部状态<b></b></span></div>
							<dl class="order-stutas bg-white hidden">
								<dt>全部状态<b></b></dt>
								<dd {if !isset($_GET[type])}class="selected"{/if}><b></b><a href="{url('member/order/index')}">全部状态</a></dd>
								<dd {if ($_GET[type] == 1)}class="selected"{/if}><b></b><a href="{url('member/order/index',array('type'=>1))}">等待付款</a></dd>
								<dd {if ($_GET[type] == 2)}class="selected"{/if}><b></b><a href="{url('member/order/index',array('type'=>2))}">等待确认</a></dd>
								<dd {if ($_GET[type] == 3)}class="selected"{/if}><b></b><a href="{url('member/order/index',array('type'=>3))}">等待发货</a></dd>
								<dd {if ($_GET[type] == 4)}class="selected"{/if}><b></b><a href="{url('member/order/index',array('type'=>4))}">等待收货</a></dd>
								<dd {if ($_GET[type] == 5)}class="selected"{/if}><b></b><a href="{url('member/order/index',array('type'=>5))}">交易完成</a></dd>
								<dd {if ($_GET[type] == 6)}class="selected"{/if}><b></b><a href="{url('member/order/index',array('type'=>6))}">交易取消</a></dd>
							</dl>
						</div>
					</div>
					<div class="td"><div class="column-narrow">操作</div></div>
				</div>
				{loop $orders $r}
					<div class="margin-top order-table border finish-order">
					    <div class="split-th split-gray">
					        <div class="td order-time">{date('Y-m-d H:i:s' ,$r[system_time])}</div>
					        <div class="td order-num">
					        	订单号：<span class="text-drak-grey">{$r[sn]}</span>
					        	<i class="arrow"></i>
					        </div>
					        {if ($r[_showsubs] == TRUE)}
					        	<div class="td margin-big-left">商品属不同商家或在不同库房，故拆分为以下订单分开配送，给您带来的不便敬请谅解。</div>
					        {else}
					        	{if (count($r[_subs][0][_group]) > 1)}
					        	<div class="td margin-big-left">商品在不同库房，故拆分为以下分开配送，给您带来的不便敬请谅解。</div>
					        	{/if}
					        {/if}
					    </div>
					    <div class="split-th">
					        <div class="td order-time">支付方式：{$r[_pay_type]}</div>
					        <div class="td order-num">订单总额：￥{$r[real_amount]}</div>
					        <div class="td w30">运费总额：￥{$r[delivery_amount]}</div>
					        <div class="td">订单状态：{if ($r[_showsubs] == TRUE) || (count($r[_subs][0][_group]) > 1)}已拆分{else}{ch_status($r[_status][wait])}{/if}</div>
					    </div>
					    <!-- 促销样式 -->
					    <!-- 循环子订单 -->
					    {loop $r['_subs'] $sub}
					    	{if $sub[promotion]}
							    <div class="th split-order">
							        <span class="text-mix"><em class="bg-light-red padding-small margin-right text-white">订单促销</em>{$sub[promotion][title]}</span>
							    </div>
						    {/if}
						    {if ($r[_showsubs] == TRUE)}
							    <div class="th split-order">
							        <div class="td order-time">{date('Y-m-d H:i:s' ,$sub[system_time])}</div>
							        <div class="td order-num">
							        	订单号：<span class="text-drak-grey">{$sub[sub_sn]}</span>
							        </div>
							        <div class="td w30">商家名称：<span class="text-drak-grey">平台自营</span></div>
							    </div>
						    {/if}
							{loop $sub[_group] $o_d_id $v}
								<div class="line">
							        <div class="td order-table-info">
							        	{loop $v[lists] $sku}
								            <div class="column-wide clearfix" data-skuid="{$sku[sku_id]}" data-number="{$sku[buy_nums]}">
								                <div class="goods-pic">
								                    <a href="{$sku['url']}"><img src="{$sku[sku_thumb]}" /></a>
								                </div>
								                <div class="goods-name">
								                    <p class="fl name">
                                                        <a href="{$sku['url']}">{$sku[sku_name]}</a>
								                    </p>
								                    <p>{$sku[_sku_spec]}</p>
								                    <!-- 商品促销样式 -->
								                    {if ($sku[is_give] == 1)}
								                    	<span class="text-mix text-lh-little margin-little-top show"><em class="fl bg-blue padding-small-left padding-small-right margin-right text-white">赠品</em></span>
								                    {/if}
								                    {if ($sku[promotion])}
								                    	<span class="text-mix text-lh-little margin-little-top show text-ellipsis"><em class="fl bg-light-red padding-small-left padding-small-right margin-right text-white">{ch_prom($sku[promotion][type])}</em>{$sku[promotion][title]}</span>
								                    {/if}
								                </div>
								                <div class="service text-gray">
								                    <span class="yahei">&times;{$sku[buy_nums]}</span>
													{if ($setting[return_time] == 1 && $sku[delivery_status] > 0)}
								                     <a class="apply-btn"  href="{url('member/service/return_refund',array('id' => $sku[id]))}" target="_blank">申请售后</a>
													{/if}
													{if ($setting[return_time] == 2 && $sku[delivery_status] == 2)}
								                     <a class="apply-btn"  href="{url('member/service/return_refund',array('id' => $sku[id]))}" target="_blank">申请售后</a>
													{/if}
								                </div>
								            </div>
								        {/loop}
						        	</div>
							        <div class="td column-narrow">{$r[address_name]}</div>
							        <div class="td column-narrow">
							            <b class="yahei">￥{$v[total_amount]}</b><br/>
							            <!-- <span class="text-gray songti text-small">{$r[_pay_type]}</span> -->
							        </div>
							        <div class="td column-narrow">
							        	<span class="text-gray">{ch_status($v[_status])}</span>
							            <br />
							        	{if ($o_d_id > 0)}
							        		<span><a href="{url('member/order/detail',array('sub_sn' =>$sub[sub_sn],'o_d_id' =>$o_d_id))}">订单详情</a></span>
							        	{else}
						            		<span><a href="{url('member/order/detail',array('sub_sn' =>$sub[sub_sn]))}">订单详情</a></span>
							        	{/if}
							            <!-- <span><a href="return&refund.html">退换货</a></span> -->
							        </div>
							        <div class="td column-narrow">
							            <div class="fl padding-left" pay-type="{$sub[pay_type]}" order-sn="{$r[sn]}" sub-sn="{$sub[sub_sn]}">
							                {if ($r[status] == 1 && $r[pay_type] == 1 && $r[pay_status] == 0)}
							                	<a class="obtn obtn2 show margin-small-bottom" href="{url('order/order/detail',array('order_sn'=>$r[sn]))}" title="点此去支付该订单">支付订单</a>
							                {/if}
							                {if ($sub[status] == 1 && $sub[confirm_status]!=2)}
							                	<a class="obtn obtn1 show margin-small-bottom action_cancel"  href="javascript:;">取消订单</a>
							                {/if}
							                {if ($sub[finish_status] == 2 || $r[status] != 1)}
							                	<a class="obtn obtn1 show margin-small-bottom action_again" href="javascript:;">再次购买</a>
							                {/if}
							                {if ($sub['status']==1 && $o_d_id > 0 && $v['delivery']['isreceive'] == 0)}
							                	<a class="obtn obtn3 show margin-small-bottom action_finish" href="javascript:;" o-d-id="{$o_d_id}">确认收货</a>
							                {/if}
							            </div>
							        </div>
							    </div>
							{/loop}
						{/loop}
					</div>
				{/loop}

				<!--拆分订单且拆分物流-->
				<!-- <div class="margin-top order-table border finish-order">
				    <div class="split-th split-gray">
				        <div class="td order-time">1970-01-01 07:59:59</div>
				        <div class="td order-num">
				        	订单号：<span class="text-drak-grey">20151111985798102112</span>
				        	<i class="arrow"></i>
				        </div>
				        <div class="td margin-big-left">商品在不同库房或属不同商家，故拆分为以下订单分开配送，给您带来的不便敬请谅解。</div>
				    </div>
				    <div class="split-th">
				        <div class="td order-time">收货人：谁啊</div>
				        <div class="td order-num">订单金额：￥224.02</div>
				        <div class="td w30">支付方式：货到付款</div>
				        <div class="td">订单状态：已拆分</div>
				    </div>
				    <div class="th split-order">
				        <div class="td order-time">2015-11-10 15:10:50</div>
				        <div class="td order-num">
				        	订单号：<span class="text-drak-grey">20151110151050975075</span>
				        </div>
				        <div class="td w30">商家名称：<span class="text-drak-grey">商家</span></div>
				    </div>
				    <div class="line">
				        <div class="td order-table-info">
				            <div class="column-wide">
				                <div class="goods-pic">
				                    <a href="" target="_blank"><img src="statics/images/no_pic.png" /></a>
				                </div>
				                <div class="goods-name">
				                    <p class="fl name">
				                        <a href="" target="_blank">2014秋装新款女中长款连帽加绒加厚针织开衫保暖女款毛衣外套</a>
				                    </p>
				                    <p>颜色：红色&nbsp;尺码：L码&nbsp;</p>
				                </div>
				                <div class="service text-gray">
				                    <span class="yahei">&times;1</span>
				                </div>
				            </div>
				        </div>
				        <div class="td column-narrow">饶家伟</div>
				        <div class="td column-narrow">
				            <b class="yahei">￥267.00</b>
				            <br />
				            <span class="text-gray songti text-small">在线支付</span>
				        </div>
				        <div class="td column-narrow">
				            <span class="text-gray">PAY</span>
				            <br />
				            <span><a href="">订单详情</a></span>
				            <br />
				        </div>
				        <div class="td column-narrow">
				            <div class="fl padding-left" data-sn="20151110151050975056">
				                <a class="obtn obtn1 show margin-small-bottom" id="cancel" href="javascript:;">取消订单</a>
				            </div>
				        </div>
				    </div>
				    <div class="th split-order">
				        <div class="td order-time">2015-11-10 15:10:50</div>
				        <div class="td order-num">
				        	订单号：<span class="text-drak-grey">20151110151050975076</span>
				        </div>
				        <div class="td w30">商家名称：<span class="text-drak-grey">商家</span></div>
				    </div>
				    <div class="line">
				        <div class="td order-table-info">
				            <div class="column-wide">
				                <div class="goods-pic">
				                    <a href="" target="_blank"><img src="statics/images/no_pic.png" /></a>
				                </div>
				                <div class="goods-name">
				                    <p class="fl name">
				                        <a href="" target="_blank">2014秋装新款女中长款连帽加绒加厚针织开衫保暖女款毛衣外套</a>
				                    </p>
				                    <p>颜色：红色&nbsp;尺码：L码&nbsp;</p>
				                </div>
				                <div class="service text-gray">
				                    <span class="yahei">&times;1</span>
				                </div>
				            </div>
				        </div>
				        <div class="td column-narrow">饶家伟</div>
				        <div class="td column-narrow">
				            <b class="yahei">￥267.00</b>
				            <br />
				            <span class="text-gray songti text-small">在线支付</span>
				        </div>
				        <div class="td column-narrow">
				            <span class="text-gray">PAY</span>
				            <br />
				            <span><a href="">订单详情</a></span>
				            <br />
				        </div>
				        <div class="td column-narrow">
				            <div class="fl padding-left" data-sn="20151110151050975056">
				                <a class="obtn obtn1 show margin-small-bottom" id="cancel" href="javascript:;">取消订单</a>
				            </div>
				        </div>
				    </div>
				    <div class="line" remark="不同快递复制一个line容器即可">
				        <div class="td order-table-info">
				            <div class="column-wide">
				                <div class="goods-pic">
				                    <a href="" target="_blank"><img src="statics/images/no_pic.png" /></a>
				                </div>
				                <div class="goods-name">
				                    <p class="fl name">
				                        <a href="" target="_blank">2014秋装新款女中长款连帽加绒加厚针织开衫保暖女款毛衣外套</a>
				                    </p>
				                    <p>颜色：红色&nbsp;尺码：L码&nbsp;</p>
				                </div>
				                <div class="service text-gray">
				                    <span class="yahei">&times;1</span>
				                </div>
				            </div>
				            <div class="column-wide">
				                <div class="goods-pic">
				                    <a href="" target="_blank"><img src="statics/images/no_pic.png" /></a>
				                </div>
				                <div class="goods-name">
				                    <p class="fl name">
				                        <a href="" target="_blank">2014秋装新款女中长款连帽加绒加厚针织开衫保暖女款毛衣外套</a>
				                    </p>
				                    <p>颜色：红色&nbsp;尺码：L码&nbsp;</p>
				                </div>
				                <div class="service text-gray">
				                    <span class="yahei">&times;1</span>
				                </div>
				            </div>
				        </div>
				        <div class="td column-narrow">饶家伟</div>
				        <div class="td column-narrow">
				            <b class="yahei">￥267.00</b>
				            <br />
				            <span class="text-gray songti text-small">在线支付</span>
				        </div>
				        <div class="td column-narrow">
				            <span class="text-gray">PAY</span>
				            <br />
				            <span><a href="">订单详情</a></span>
				            <br />
				        </div>
				        <div class="td column-narrow">
				            <div class="fl padding-left" data-sn="20151110151050975056">
				                <a class="obtn obtn1 show margin-small-bottom" id="cancel" href="javascript:;">取消订单</a>
				                <a class="obtn obtn2 show margin-small-bottom" id="cancel" href="javascript:;">支付订单</a>
				                <a class="obtn obtn3 show margin-small-bottom" id="cancel" href="javascript:;">确认订单</a>
				            </div>
				        </div>
				    </div>
				</div> -->

				<div class="paging margin-top margin-bottom padding-tb clearfix" data-page="{$_GET[page]}">
					<ul class="fr">{$pages}</ul>
				</div>
			</div>
		</div>
	</div>
</div>
{template footer common}

<script>
	$(function(){
		//点击到指定页
		$(".paging .button").click(function(){
			jump_to_page(this);
		});
		//回车到指定页
		$(".paging input[name=page]").live('keyup',function(e){
			if(e.keyCode == 13){
				jump_to_page(this);
			}
		});
	})
	$(window).load(function(){
		if($(".finish-order").length<=0){
			$(".order-table-th").after('<p class="margin-big-top text-center">暂无订单信息！</p>');
		}
	})

	$(".o-stutas-filter .open").click(function(){
		$(".o-stutas-filter .order-stutas").removeClass("hidden");
	});
	$(".o-stutas-filter .order-stutas dt").click(function(){
		$(this).parent().addClass("hidden");
	});
	$(".o-stutas-filter .order-stutas dd").click(function(){
		$(this).addClass("selected").siblings().removeClass("selected");
		$(this).parent().addClass("hidden");
	});

	$(".order-menu li a").bind('mouseover',function(){
		var _left = $(this).offset().left-$(".order-menu").offset().left;
		$(".mat").stop().animate({left:_left+"px",width:$(this).width()},300);
	});
	$(".order-menu").bind('mouseleave',function(){
		orderMenuAutoSlide(300);
	});
	function orderMenuAutoSlide(timer){
		var num = 0;
		var width = 0;
		$(".order-menu li").each(function(){
			if($(this).children("a").hasClass("current")){
				num = $(this).children("a").offset().left;
				width = $(this).children("a").width();
			}
		});
		$(".mat").stop().animate({left:num-$(".order-menu").offset().left+"px",width:width},timer).show();
	}
	orderMenuAutoSlide(0);

	//已完成订单的订单删除按钮
	$(".finish-order").hover(function(){
		$(this).find(".reclaim").show();
	},function(){
		$(this).find(".reclaim").hide();
	});
</script>